new Vue({
	el: '#app',
	computed: {
		cs() {
			return this.course;
		}
	},
	mounted() {
		let courseStr = localStorage.getItem("course");
		const courseObj = JSON.parse(courseStr);
		this.course = courseObj;
	},
	data: {
		name: '',
		price: 0,
		course: []
	},
	methods: {
		save() {
			let c = {
				id: Math.ceil(Math.random() * 10000),
				name: this.name,
				price: this.price
			}
			this.course.unshift(c);
		},
		del(id, index) {
			this.course.splice(index, 1);
		},
		query() {
			const arr = this.course.filter(val => {
				return val.name.includes(this.name)
			});
			this.course = arr;
		}
	},
})
